// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import App from './App'
import router from './router'
import FastClick from 'fastclick'
import 'babel-polyfill' // 解决安卓不支持promise 白屏问题
import store from './store/store'
import axios_ from '../static/js/axios'

import VueLazyload from 'vue-lazyload'
// 导入Antd
import Antd from 'ant-design-vue'
import '../static/css/jQuery.scrollSomething-1.0.0.css'
import '../static/css/border.css'
import '../static/css/reset.css'
import 'ant-design-vue/dist/antd.css'
import '../static/css/scrollbar.css'
import '../static/css/indexcommon.css'
import 'swiper/dist/css/swiper.css'
import Vuex from 'vuex'
import urls from './common.js'
import VueResource from 'vue-resource'
// 富文本编辑器
import Mint from 'mint-ui'
import 'mint-ui/lib/style.css'

Vue.use(Vuex)
Vue.use(Mint)
Vue.use(VueLazyload, {
  preLoad: 1.3, // 预加载高度比例
  // error: errImg, // 图片路径错误时加载图片
  // loading: loadingImg, // 预加载图片
  attempt: 1, // 尝试加载图片数量
  // set observer to true
  observer: true,
  // optional
  observerOptions: {
    rootMargin: '0px',
    threshold: 0.1
  }
})
Vue.prototype.$httppp = axios_
Vue.prototype.common = urls
Vue.prototype.clearSettime = ''
Vue.prototype.dateObj = {}

Vue.prototype.timeFormate = function () { // timeFormate是函数名
  let year = new Date().getFullYear()
  let month =
    new Date().getMonth() + 1 < 10
      ? '0' + (new Date().getMonth() + 1)
      : new Date().getMonth() + 1
  let date =
    new Date().getDate() < 10
      ? '0' + new Date().getDate()
      : new Date().getDate()
  let hh =
    new Date().getHours() < 10
      ? '0' + new Date().getHours()
      : new Date().getHours()
  let mm =
    new Date().getMinutes() < 10
      ? '0' + new Date().getMinutes()
      : new Date().getMinutes()
  this.nowTime =
    year + '年' + month + '月' + date + '日' + ' ' + hh + ':' + mm
}
Vue.prototype.toLocaleString = function () {
  var _this = this
  return _this.$http.get(urls.currentTime)
}

Vue.prototype.addZero = function (num) {
  if (num < 10) { return '0' + num }
  return num
}
Vue.config.productionTip = false
// Vue.use(store)
Vue.use(Antd)
Vue.use(VueResource)
// 让点击事件没有300ms延迟
FastClick.attach(document.body)
// 滑动插件swiper
Vue.use(VueAwesomeSwiper)
/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  router,
  components: { App },
  template: '<App/>',
  data: {
    Bus: new Vue()
  }
})
